CREATE TABLE [dbo].[C_MATCHTEAMS]
(
[cup] [numeric] (4, 0) NOT NULL,
[matchId] [numeric] (2, 0) NOT NULL,
[teamOrd] [numeric] (1, 0) NOT NULL,
[team] [varchar] (25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[goals] [numeric] (2, 0) NOT NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[C_MATCHTEAMS] ADD CONSTRAINT [ch_C_MatchTeams_goal] CHECK (([goals]>=(0)))
GO
ALTER TABLE [dbo].[C_MATCHTEAMS] ADD CONSTRAINT [ch_C_MatchTeams_ord] CHECK (([teamOrd]>(0) AND [teamOrd]<=(2)))
GO
ALTER TABLE [dbo].[C_MATCHTEAMS] ADD CONSTRAINT [pk_C_MatchTeams] PRIMARY KEY CLUSTERED  ([cup], [matchId], [teamOrd]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[C_MATCHTEAMS] ADD CONSTRAINT [pk_C_MatchTeams_team] UNIQUE NONCLUSTERED  ([cup], [matchId], [team]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[C_MATCHTEAMS] ADD CONSTRAINT [fk_C_MatchTeams_match] FOREIGN KEY ([cup], [matchId]) REFERENCES [dbo].[C_MATCHES] ([cup], [matchId])
GO
ALTER TABLE [dbo].[C_MATCHTEAMS] ADD CONSTRAINT [fk_C_MatchTeams_team] FOREIGN KEY ([team]) REFERENCES [dbo].[C_TEAMS] ([team])
GO
